package com.jingjiu.homeservicesbiz.controller;

import com.jingjiu.homeservicesapi.Vo.LoginVo;
import com.jingjiu.homeservicesapi.dto.UserDTO;
import com.jingjiu.homeservicesapi.dto.UserLoginDTO;
import com.jingjiu.homeservicesapi.util.R;

import com.jingjiu.homeservicesbiz.service.UserLoginServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserLoginController {



    @Autowired
    private UserLoginServer userLoginServer;
    /**
     * 账号密码登录
     * @param
     * @return
     */
    @PostMapping("/login")
    public R<LoginVo> login(@RequestBody UserLoginDTO userLoginDTO) {
        //登陆完毕返回token和用户类型
     return R.ok(userLoginServer.userLogin(userLoginDTO.getAccount(), userLoginDTO.getPassword()));
    }


    /**
     * 账号密码注册
     * @param
     * @return
     */
    @PostMapping("/register")
    public R register(@RequestBody UserDTO userDTO) {
        return R.ok(userLoginServer.userRegister(userDTO));
    }
}